<template>
  <div style="padding-left:10px; padding-right: 10px; width: calc(100vw - 200px)">
    <!--    搜索区域-->
    <div style="margin: 10px 0">
      <span style="color: #611ee3;font-size: large;">课程名：</span>
      <el-input v-model="search" placeholder="请输入课程名" style="width: 20%" clearable></el-input>
      <el-button style="margin-left: 5px; background-color: #409EFF; color: white" @click="load" plain>查询</el-button>
    </div>
    <el-table
        :data="tableData"
        border
        stripe
        style="width: 100%">
      <el-table-column
          prop="courseId"
          label="ID"
          sortable>
      </el-table-column>
      <el-table-column
          prop="userName"
          label="学员名">
      </el-table-column>
      <el-table-column
          prop="courseName"
          label="课程名">
      </el-table-column>
      <el-table-column
          label="课程封面">
        <template #default="scope">
          <div class="demo-imaeg__preview">
            <el-image
                style="width: 100px; height: 100px"
                :src="scope.row.courseImg"
                :preview-src-list="[scope.row.courseImg]">
            </el-image>
          </div>
        </template>
      </el-table-column>
      <el-table-column
          prop="startDate"
          label="开始时间">
      </el-table-column>
      <el-table-column
          prop="endDate"
          label="结束时间">
      </el-table-column>
      <el-table-column
          prop="courseInfo"
          label="课程信息">
      </el-table-column>
      <el-table-column
          label="课程状态">
        <template #default="scope">
          <span v-if="scope.row.courseStatus==='1'">未开始</span>
          <span v-if="scope.row.courseStatus==='2'">进行中</span>
          <span v-if="scope.row.courseStatus==='3'">已结束</span>
        </template>
      </el-table-column>
    </el-table>

  </div>
</template>

<script>


import request from "@/utils/request";
import XLSX from "xlsx";

export default {
  name: 'course',
  components: {},
  data() {
    return {
      form: {},
      search: '',
      tableData: [],
      user: {},
      coachId: '',
      price: 0,
      member:{},
    }
  },
  created() {
    let Str = sessionStorage.getItem("coach") || '{}';
    this.coachId = JSON.parse(Str).id;
    this.load();
  },
  methods: {
    load() {
      request.get("/api/coach/getCourseByCoachId", {
        params: {
          search: this.search,
          coachId:this.coachId
        }
      }).then(res => {
        console.log(res);
        this.tableData = res.data
      })
    },
    handleSizeChange(pageSize) {//改变当前页面个数
      this.pageSize = pageSize;
      this.load();
    },
    handleCurrentChange(pageNum) {//改变当前页码
      this.currentPage4 = pageNum;
      this.load();
    },

    filesUploadSuccess(res) {
      console.log(res);
      this.form.courseImg = res.data;
      this.load();
    }

  }
}
</script>
